/**
 * 加载框架的模块
 */
const Knex = require('knex')
const Moss = require('../../utils/moss')
const dayjs = require('dayjs')

require('dayjs/locale/zh-cn')
dayjs.locale('zh-cn')

module.exports = app => {
  app.knex = Knex({
    ...app.config.knex,
    log: {
      debug(message) {
        const sql = app.knex.raw(message.sql, message.bindings).toString()

        console.log('[Knex]', sql)
      },
    },
  })

  app.moss = new Moss(app.knex)
  app.dayjs = dayjs
}
